import pymysql
class Serve():

    def sql_serve(self,image):
        conn = pymysql.connect(host='sh-cdb-gelid84k.sql.tencentcdb.com',
                               port=63573,
                               user='root',
                               password='YinQuanHang@888',
                               charset='utf8',
                               db='bwc')
        cursor = conn.cursor()
        sql = "select shopstore_id from gyh_order where imgone = %s"
        cursor.execute(sql,(image))
        result = cursor.fetchall()
        if result == ():
            content = 'null'
        else:
            content = result[0][0]
        return content
    def getting_shop(self,number):
        shopstore_id = number
        conn = pymysql.connect(host='sh-cdb-gelid84k.sql.tencentcdb.com',
                               port=63573,
                               user='root',
                               password='YinQuanHang@888',
                               charset='utf8',
                               db='bwc')
        cursor = conn.cursor()
        sql = "select name from gyh_shopstore where id = %s"
        cursor.execute(sql,(shopstore_id))
        result = cursor.fetchall()
        if result == ():
            print('地址无效，有错误')
            content = 'null'
        else:
            content = result[0][0]
        return content,shopstore_id
"""测试代码"""
# text = 'https://q-bwc.oss-cn-shanghai.aliyuncs.com/order/bc0b8056-39cf-4e3c-abaf-f960d58920fd.jpg'
# test = Serve()
# result = test.sql_serve(text)
# result = test.getting_shop(result)
# print(result)
#
#



